<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->char('code',8)->default('')->unique()->comment('产品编号');
            $table->string('name',100)->default('')->comment('产品名称');
            $table->string('unit',20)->default('')->comment('单位');
            $table->text('description')->comment('描述');
            $table->integer('supplier_id')->unsigned()->index()->default(0)->comment('供应商ID');
            $table->tinyInteger('is_virtual')->unsigned()->default(0)->comment('是否虚拟，0-否,1-是');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('状态，0-下架（默认），1-上架');
            $table->decimal('cost_price',8,2)->default('0.00')->unsigned()->comment('参考成本价格');
            $table->decimal('sale_price',8,2)->default('0.00')->unsigned()->comment('销售价格');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `products` comment '产品表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
